package com.example.chapter3_3.dao;

import com.example.chapter3_3.entity.User;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserDao {

    @Results(id = "userMap",value = {
            @Result(property = "name",column = "username"),
            @Result(property = "sex",column = "sex"),
            @Result(property = "password",column = "password")
    })


    @Select("select * from user where name = #{username} and password=#{password}")
    User getUserByName(@Param("username") String name, String password);


    @Select("select count(1) from user where name = #{name}")
    int findUserByName(User user);

    @Insert("insert into user(name,password,sex) values (#{name},#{password},#{sex})")
    int creatUser(User user);
}